#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const *argv[])
{
    int n, *a, *b, *g, *k, x, y;
    int i, result;
    scanf("%d", &n);
    a = (int *)malloc(sizeof(int) * n);   
    b = (int *)malloc(sizeof(int) * n);   
    g = (int *)malloc(sizeof(int) * n);   
    k = (int *)malloc(sizeof(int) * n);   
    for (i = 0; i < n; i++)
    {
        scanf("%d%d%d%d", &a[i], &b[i], &g[i], &k[i]);
    }
    scanf("%d%d", &x, &y);
    result = -1;
    for (i = 0; i < n; i++)
    {
        if (x >= a[i] 
            && x <= a[i] + g[i] 
            && y >= b[i] 
            && y <= b[i] + k[i])
        {
            result = i+1;
        }
    }
    printf("%d", result);
    return 0;
}
